/**
 * Project Name:imgo-b2b-resource
 * @File: ResultCode.java
 * @Package: com.cmdt.imgo.b2b.resource.common
 * Copyright (c) 2019 Neusoft Group Ltd. All Rights Reserved.
 * Neusoft PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.xnyzc.lhy.resource.entity.jpush;

/**
 * @ClassName: ResultCode
 * @Description: TODO
 * @author majch
 * @date 2019-02-26
 * @since OpenJDK 1.8
 */

public enum ResultCode {
	/* 成功状态码 */
	SUCCESS(1, "OK"),

	/* 参数错误码10001-19999 */
	REQ_NOT_COMPLETE(10001, "请求信息中缺少必要参数"), REQ_IS_INVALID(10002, "请求参数不符合规范"),
	REQ_NO_CLIENT_ID(10003, "请求信息中缺少client_id信息或数据非法"), REQ_NO_SEQ(10004, "请求信息中缺少t_seq信息或数据非法"),

	/* 认证信息错误码20001-29999 */
	USER_NOT_LOGGED_IN(20001, "缺少认证令牌信息"), USER_LOGIN_ERROR(20002, "认证令牌信息异常"), USER_ACCOUNT_FORBIDDEN(20003, "账号已被禁用"),
	USER_NOT_EXIST(20004, "用户不存在"), USER_HAS_EXISTED(20005, "用户已存在"),

	/* 业务错误码30001-39999 */
	SPECIFIED_QUESTIONED_USER_NOT_EXIST(30001, "某业务出现问题"),
	FDFS_QUESTIONED_EXIST(30001, "FDFS业务出现问题"),
	SMS_QUESTIONED_EXIST(31001, "短信业务出现问题"),
	MSG_QUESTIONED_EXIST(32001, "消息业务出现问题"),
	MAIL_QUESTIONED_EXIST(33001, "消息业务出现问题"),
	/* 数据错误码40001-49999 */
	RESULE_DATA_NONE(40001, "数据未找到"), DATA_IS_WRONG(40002, "数据有误"), DATA_ALREADY_EXISTED(40003, "数据已存在"),

	/* 接口错误码50001-59999 */
	INTERFACE_INNER_INVOKE_ERROR(50001, "内部系统接口调用异常"), INTERFACE_OUTTER_INVOKE_ERROR(50002, "外部系统接口调用异常"),
	INTERFACE_FORBID_VISIT(50003, "该接口禁止访问"), INTERFACE_ADDRESS_INVALID(50004, "接口地址无效"),
	INTERFACE_REQUEST_TIMEOUT(50005, "接口请求超时"), INTERFACE_EXCEED_LOAD(50006, "接口负载过高"),

	/* 权限错误码60001-69999 */
	PERMISSION_NO_ACCESS(60001, "无访问权问"),

	/* 系统错误码90001-99999 */
	SYSTEM_BUSY(90001, "系统繁忙，请稍后重试"), INTERNAL_SERVER_ERROR(99999, "系统内部异常");

	private Integer code;

	private String message;

	ResultCode(Integer code, String message) {
		this.code = code;
		this.message = message;
	}

	public Integer code() {
		return this.code;
	}

	public String message() {
		return this.message;
	}

	public static String getMessage(String name) {
		for (ResultCode item : ResultCode.values()) {
			if (item.name().equals(name)) {
				return item.message;
			}
		}
		return name;
	}

	public static Integer getCode(String name) {
		for (ResultCode item : ResultCode.values()) {
			if (item.name().equals(name)) {
				return item.code;
			}
		}
		return null;
	}

	@Override
	public String toString() {
		return this.name();
	}
}
